package com.edu.employee.controller.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ProjectName: summer-project
 * @Titile: UserLoginConfig
 * @Author: Lucky
 * @Description: 注册拦截器
 */
//@Configuration //注解类
//@SpringBootConfiguration //更加具有语义，配置类注解
public class UserLoginConfig implements WebMvcConfigurer {
    //自动注入拦截器
    //@Autowired
    private UserLoginInterceptor userLoginInterceptor;

    /**
     * 注册拦截器的方法
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userLoginInterceptor)//注册拦截器
                .addPathPatterns("/**") //拦截所有
                .excludePathPatterns("/api/user/login");//放行
    }
}
